﻿(function () {
    var Factory = function () {
        this.fallingObjects = [
        tetris.FallingL,
        tetris.FallingLine,
        tetris.FallingLReversed,
        tetris.FallingSquare,
        tetris.FallingZ,
        tetris.FallingZReversed,
        tetris.FallingT];
    };
    Factory.prototype = {
        createFallingObject: function (x,y) {
            x = x || 0;
            y = y || 0;
            var index = parseInt(Math.random() * this.fallingObjects.length);
            var topBorder = 200;
            var red = parseInt(Math.random() * topBorder);
            var green = parseInt(Math.random() * topBorder);
            var blue = parseInt(Math.random() * topBorder);
            var falling = new this.fallingObjects[index](x,y, "rgb("+red+","+green+","+blue+")");
            return falling;
        },
    };

    tetris.Factory = Factory;
})();